package com.gitee.yannzh.rune.core.exception;

/**
 * @author yann
 * @description:
 * @date 2022/2/15 14:19
 * @version：1.0
 */
public class SystemException extends RuntimeException {

    private Throwable source;

    public SystemException(Throwable exp) {
        super(exp);
        this.source = exp;
    }

    public SystemException(String message) {
        super(message);
    }

    public SystemException(String message, Throwable cause) {
        super(message, cause);
        this.source = cause;
    }

    public Throwable getSource() {
        if (this.source == null) {
            return null;
        }
        if (this.source instanceof SystemException) {
            return ((SystemException) this.source).getSource();
        }
        return source;
    }
}
